package com.xxxx.worm;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;

import java.io.UnsupportedEncodingException;

public class WormObj {
    private Document document;//网页对象
    private String url;
    private String charset;//字符编码
    private String contentType;//内容类型
    private String html;//源码
    private byte[] content;//字节码

    public Document getDocument() {
        document = Jsoup.parse(getHtml(), url);
        return document;
    }

    public String getUrl() {
        return url;
    }

    public String getCharset() {
        return charset;
    }

    public String getContentType() {
        return contentType;
    }

    public String getHtml() {
        try {
            html = new String(content, charset);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return html;
    }

    public byte[] getContent() {
        return content;
    }

    public WormObj(String url, String contentType, byte[] content) {
        this.url = url;
        this.contentType = contentType;
        this.content = content;
        charset="UTF-8";
    }



}
